package com.loveazure.ui.action;

import java.awt.event.ActionEvent;

import javax.swing.JOptionPane;

import com.loveazure.bll.Handler;
import com.loveazure.ui.ConfigPanel;

public class DeleteUserCourseAction extends ConfigPanelAction {

	private static final String DELETE_USER_COURSE = "删除课程";

	public DeleteUserCourseAction(ConfigPanel panel) {
		super(panel, DELETE_USER_COURSE);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (panel.table.getSelectedRow() == -1) {
			return;
		}
		int i = JOptionPane.showConfirmDialog(panel, "确认删除", "",
				JOptionPane.YES_NO_OPTION);
		if (i == 0) {
			Handler.getInstance().getOper().deleteUserCourse(
					panel.model.getRow(panel.table.getSelectedRow()));
			panel.model.deleteRow(panel.table.getSelectedRow());
		}
	}

}
